/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.aptech.DAO;
import com.aptech.model.BankLoan;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;

/**
 *
 * @author Hoang Quy Hong An
 */
public class bankLoanDAO {
      private Connection myCon = null;
    private PreparedStatement ps = null;
    private ResultSet rs = null;
    private String strCommand = "";

public ArrayList<BankLoan> getRealEstateByType(int bankID) {
        ArrayList<BankLoan> listBankLoan = new ArrayList<BankLoan>();
        strCommand = "SELECT bankLoanId ,bankID ,bankLoanName ,Maximum ,Minimum ,loanDescription ," +
                "DurationOfLoan FROM tbl_BankLoan where bankID = ? and bankLoanStatus = 1";
        BankLoan objBankLoan = null;
        try {
            myCon = myConnection.getConnection();
            ps = myCon.prepareStatement(strCommand, ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
            ps.setInt(1, bankID);
            rs = ps.executeQuery();
            while (rs.next()) {
                objBankLoan = new BankLoan();
                objBankLoan.setBankLoanId(rs.getInt("bankLoanId"));
                objBankLoan.setBankID(bankID);
                objBankLoan.setBankLoanName(rs.getString("bankLoanName"));
                objBankLoan.setMaximum(rs.getFloat("Maximum"));
                objBankLoan.setMinimum(rs.getFloat("Minimum"));
                objBankLoan.setLoanDescription(rs.getString("loanDescription"));
                objBankLoan.setDurationOfLoan(rs.getInt("DurationOfLoan"));
                listBankLoan.add(objBankLoan);
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            myConnection.closeConnection(myCon, ps, rs);
        }
        return listBankLoan;
    }
}
